package com.wyvoid.forum.dao.hibernate;

import com.wyvoid.core.persistent.Pagination;
import com.wyvoid.core.persistent.hibernate.HibernateDAO;
import com.wyvoid.core.persistent.hibernate.HibernatePage;
import com.wyvoid.forum.dao.IAttachmentDAO;
import com.wyvoid.forum.domain.Attachment;

/**
 * 帮助信息Hibernate数据处理实现
 *
 * @author wyvoid
 * @version $Revision: 1.7 $ $Date: 2006/08/07 17:39:06 $
 * @link www.wyvoid.com
 */
public class AttachmentDAO extends HibernateDAO<Attachment> implements IAttachmentDAO {


    /**
     * 取得制定用户的附件列表
     *
     * @param userId     用户编号
     * @param filetype   文件类型
     * @param pagination 分页对象
     * @return QueryResult 论坛贴子列表
     */
    public HibernatePage<Attachment> findAttachments(int userId, String filetype, Pagination pagination) {
        if (filetype == null) {
            String hql = "from Attachment where userId=? ";
            return doQuery(hql, true, pagination, userId);
        } else {
            String hql = "from Attachment where userId=? and fileType=?";
            return doQuery(hql, true, pagination, userId, filetype);
        }
    }
}